//
//  ControllerTest.m
//  HelloPoly
//
//  Created by Lefty Fabulous on 8/30/09.
//  Copyright 2009 __MyCompanyName__. All rights reserved.
//

#import "PolyDelegateTest.h"
#import "PolyDelegate.h"


@implementation PolyDelegateTest


- (void)testSetUp {
	STAssertNotNil(dlg, @"PolyDelegate should have been created by setUp");
	STAssertNotNil(dlg.shape, @"Delegate's shape was nil");
}

- (void)testInit {
	STAssertEquals(5, [dlg.shape numberOfSides],
				   @"Expected %d but was %d instead", 5, [dlg.shape numberOfSides]);
}

- (void) testIncrease {
	STAssertEquals(5, [dlg.shape numberOfSides],
				   @"Expected %d but was %d instead", 5, [dlg.shape numberOfSides]);
	[dlg increase];
	STAssertEquals(6, [dlg.shape numberOfSides],
				   @"Expected %d but was %d instead", 6, [dlg.shape numberOfSides]);
	// Cannot increase above max number of sides
	[dlg.shape setNumberOfSides:12];
	STAssertEquals(12, [dlg.shape numberOfSides],
				   @"Expected %d but was %d instead", 12, [dlg.shape numberOfSides]);
	[dlg increase];
	STAssertEquals(12, [dlg.shape numberOfSides],
				   @"Expected %d but was %d instead", 12, [dlg.shape numberOfSides]);
	
}

- (void) testDecrease {
	STAssertEquals(5, [dlg.shape numberOfSides],
				   @"Expected %d but was %d instead", 5, [dlg.shape numberOfSides]);
	[dlg decrease];
	STAssertEquals(4, [dlg.shape numberOfSides],
				   @"Expected %d but was %d instead", 4, [dlg.shape numberOfSides]);
	// Cannot decrease below min number of sides
	[dlg.shape setNumberOfSides:3];
	STAssertEquals(3, [dlg.shape numberOfSides],
				   @"Expected %d but was %d instead", 3, [dlg.shape numberOfSides]);
	[dlg decrease];
	STAssertEquals(3, [dlg.shape numberOfSides],
				   @"Expected %d but was %d instead", 3, [dlg.shape numberOfSides]);
	
}

- (void)setUp {
	[super setUp];
	dlg = [[PolyDelegate alloc] init];
	[dlg initializeShape:5];
}
- (void)tearDown {
	[dlg autorelease];
	[super tearDown];
}
@end
